<html>
<head>
<script type="text/javascript" >

function main(ev)
{
    //alert(ev);
    c = document.getElementById("canvas");
    x = ev.layerX
    y = ev.layerY;
    ctx =  c.getContext('2d');
    ctx.beginPath();
    ctx.strokeStyle= "rgb(255,0,0)";
    ctx.moveTo(x,y);
    ctx.lineTo(0,0);
    ctx.stroke();
    
}
function start()
{
    c = document.getElementById("canvas");
    c.addEventListener("mousemove", main, false);

}
//document.onmousedown = main;
</script>

</head>
<body onload="start()">
<canvas id="canvas" width="640" height="480" style="background:black" />
</body>
</html>

